<?php


namespace app\admin\model;

use think\Model;

class Admin extends Model
{
    //登录核对
    public static function login($username, $password){
        return self::where('username', $username)
            ->where('password', $password)
            ->find();
    }

    //注册
    public static function register($data)
    {
        return self::create($data);
    }

    //更新用户名
    public static function upUsername($oldname,$newname)
    {
        return self::where('username',$oldname)
            ->data(['username'=> $newname])
            ->update();
    }

    //更新当前用户密码
    public static function upUserInfo($where,$newpwd)
    {
        return self::where('username', $where)
            ->data(['password' => $newpwd])
            ->update();
    }
}